Title: SQL W3S (By-BKK) / 001 Intro
Tags: Obsidian_to_Anki

Q: Expand SQL
A: Structured Query Language

Q: What is SQL used for?
A: Storing, manipulating, and retrieving data in databases

Q: True/False: SQL is only used for MySQL databases
A: False

Q: Which SQL command is used to select all records from the 'Customers' table?
A: SELECT * FROM Customers;

Q: What does SELECT DISTINCT do in SQL?
A: Returns only distinct (different) values

Q: How do you filter records in SQL?
A: Use the WHERE clause

Q: Which SQL clause sorts results?
A: ORDER BY

Q: True/False: SQL AND is used to combine multiple conditions in WHERE
A: True

Q: What does SQL OR do in a query?
A: Combines multiple conditions, true if any condition is true

Q: How does SQL NOT modify a condition?
A: NOT negates a condition in SQL queries

Q: What is the command to add new data to a table?
A: INSERT INTO

Q: How do you update existing data in SQL?
A: Use UPDATE statement

Q: How can you remove data from a table in SQL?
A: Use DELETE statement

Q: Which command restricts results to a specific number of rows?
A: SELECT TOP

Q: How are calculations like SUM and COUNT done in SQL?
A: Using aggregate functions

Q: What does SQL GROUP BY do?
A: Groups rows sharing a property, like department

Q: True/False: HAVING can be used with GROUP BY to filter grouped results
A: True

Q: What is the purpose of SQL LIKE and wildcards?
A: To search for patterns in data

Q: What does SQL IN do?
A: Checks if a value matches any value in a set

Q: How does SQL BETWEEN work?
A: Finds values within a range

Q: How do you rename a column or table temporarily in SQL?
A: Use AS keyword for aliases

Q: What is an SQL JOIN?
A: Combines rows from two or more tables

Q: What does INNER JOIN mean?
A: Returns records with matching values in both tables

Q: Left Join returns all records from which table?
A: All records from the left table, matched from the right

Q: What does SQL RIGHT JOIN do?
A: Returns all records from the right table, matched from the left

Q: What is FULL JOIN’s result in SQL?
A: All records when there is a match in either left or right table

Q: How does Self Join work?
A: A table is joined with itself

Q: True/False: SQL UNION stacks results vertically
A: True

Q: How does SQL UNION ALL differ from UNION?
A: UNION ALL includes duplicates

Q: What does EXISTS test in SQL?
A: If a subquery returns any results

Q: Any and All in SQL apply to what kind of comparison?
A: Subqueries comparing values from lists

Q: What is the purpose of SELECT INTO?
A: Creates a new table from a query result

Q: How is INSERT INTO SELECT used?
A: Copies data from one table into another

Q: What does SQL CASE do?
A: Runs conditional logic, similar to IF-ELSE

Q: How do you handle NULL values in SQL?
A: Use IS NULL, IS NOT NULL, or NULL functions

Q: What is an SQL Stored Procedure?
A: A saved collection of SQL statements for reuse

Q: How do you add explanations to SQL code?
A: Use comments (-- or /* */)

Q: Which operator compares if values are equal in SQL?
A: Equal to Symbol =

Q: How do you create a database in SQL?
A: CREATE DATABASE

Q: Which command deletes a database?
A: DROP DATABASE

Q: How do you backup a database in SQL?
A: Use BACKUP DATABASE

Q: What does CREATE TABLE do?
A: Creates a new table in the database

Q: What is the DROP TABLE command for?
A: Deletes a table and its data

Q: How do you change a table structure in SQL?
A: Use ALTER TABLE

Q: What is a constraint in SQL?
A: A rule that limits the values in a column

Q: True/False: NOT NULL prevents empty column values
A: True

Q: What does UNIQUE constraint mean?
A: Ensures all values in a column are different

Q: Which key uniquely identifies a row in SQL?
A: PRIMARY KEY

Q: How does FOREIGN KEY work?
A: Links one table to another

Q: What does CHECK constraint verify?
A: Ensures values meet a condition

Q: How is a default value set in SQL?
A: Use DEFAULT constraint

Q: What does SQL INDEX do?
A: Speeds up searches on a table

Q: True/False: AUTO INCREMENT helps add unique numbers to rows
A: True

Q: What does SQL DATE handle?
A: Stores date and time data

Q: What is a SQL VIEW?
A: A virtual table based on a query

Q: True/False: SQL Injection is a security issue
A: True

Q: How do you find SQL data type details?
A: Use SQL Data Types Reference

Q: Paris
A: What is the capital of France?

Q: SELECT * FROM Customers;
A: Which SQL command selects all records from 'Customers'?

Q: PRIMARY KEY
A: Which constraint uniquely identifies a row?

Q: True
A: NOT NULL prevents empty values in a column

Q: UNION
A: Which SQL operator stacks query results vertically?

Q: What does SQL stand for?
A: Structured Query Language

Q: SQL is used to access and manipulate what?
A: Databases

Q: True/False: SQL is an ANSI and ISO standard
A: True

Q: When did SQL become an ANSI standard?
A: 1986

Q: Which organization standardized SQL in 1987?
A: International Organization for Standardization (ISO)

Q: What can SQL execute against a database?
A: Queries

Q: How does SQL retrieve data from a database?
A: Using SELECT queries

Q: Which SQL operation adds new records to a database?
A: INSERT

Q: What operation does UPDATE perform in SQL?
A: Modifies records in a database

Q: How do you remove records using SQL?
A: With the DELETE command

Q: Which SQL command creates new databases?
A: CREATE DATABASE

Q: How can SQL create new tables?
A: With CREATE TABLE

Q: True/False: SQL can create stored procedures and views
A: True

Q: How can you set permissions using SQL?
A: On tables, procedures, and views

Q: SQL commands like SELECT, UPDATE, DELETE, INSERT, WHERE are supported in which standard?
A: ANSI SQL

Q: True/False: Different SQL versions exist and include proprietary extensions
A: True

Q: What do you need to build a website with data from a database?
A: An RDBMS, server-side scripting, SQL, and HTML/CSS

Q: What does RDBMS stand for?
A: Relational Database Management System

Q: What is the basis for SQL and modern databases?
A: RDBMS

Q: Name some popular RDBMS database systems
A: MS SQL Server, IBM DB2, Oracle, MySQL, Microsoft Access

Q: How is data stored in RDBMS?
A: In tables

Q: What is a table in SQL?
A: A collection of related data entries with columns and rows

Q: What are the vertical entities in a table called?
A: Columns or fields

Q: What is a horizontal entity in a table?
A: A row or record

Q: CustomerID, CustomerName, Address are examples of what in a SQL table?
A: Fields (columns)

Q: What shows all records from the Customers table?
A: SELECT * FROM Customers;